package com.aike.controller;

import com.aike.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/Grade", produces={"text/html;charset=UTF-8;","application/json;"})
public class GradeController {

    @Autowired
    private GradeService gradeService;

    @RequestMapping("/gradePage")
    public String gradePage(@RequestParam("userId") Integer userId)
    {
        return gradeService.getGradeList(userId);
    }

    @RequestMapping("/gradeShowPage")
    public String gradeShowPage(@RequestParam("userId") Integer userId, @RequestParam("gradeId") Integer gradeId)
    {
        return gradeService.getGradeShow(userId, gradeId);
    }

    @RequestMapping("/saveGrade")
    public String saveGrade(@RequestParam("gradeId") Integer gradeId, @RequestParam("gradeNum") Integer gradeNum)
    {
        return gradeService.saveGrade(gradeId, gradeNum);
    }

    @RequestMapping("/addNewGradeAnswer")
    public String addNewGradeAnswer(@RequestParam("userId") Integer userId,@RequestParam("taskId") Integer taskId,@RequestParam("gradeAnswer") String gradeAnswer)
    {
        return gradeService.addNewTaskAnswer(userId, taskId, gradeAnswer);
    }

}
